'use stricr'

// var from =$('#test-form'),

// langs = from.find('[name=lang]'),

// selectAll = from.find('label.selectAll :checkbox'),

// deselectAllLabel = from.find('span.deselectAll'),

// selectAllLabel = from.find('span.selectAll'),

// invertSelect = from.find('a.invertSelect');


var 

from = $('#test-form'),

langs = from.find('[name=lang]'),

selectAll = from.find('label.selectAll :checkbox'),

deselectAllLabel = from.find('span.deselectAll'),

selectAllLabel = from.find('span.selectAll'),

invertSelect = from.find('a.invertSelect');

//打印
console.log(from);
console.log(langs);
console.log(selectAll);
console.log(deselectAllLabel);
console.log(selectAllLabel);
console.log(invertSelect);


langs.click(function(){
    if(langs.not(':checked').length===0){
        selectAll.prop('checked',true);

        selectAllLabel.css('display','none');

        deselectAllLabel.css('display','inline');
    }
    else{
        selectAll.prop('checked',false);

        selectAllLabel.css('display','inline');

        deselectAllLabel.css('display','none');
    }
}); 

// langs.click(function(){
//     if(langs.not(':checked').length!==0){
//         selectAll.prop('checked',false);
//     }
// });



selectAll.click(function(){
    if(selectAll.is(':checked')){
        langs.prop('checked',true);

        selectAllLabel.css('display','none');

        deselectAllLabel.css('checked','inline');
    }
    else{
        langs.prop('checked',false);

        selectAllLabel.css('display','inline');

        deselectAllLabel.css('display','name')
    }
});



invertSelect.click(function(){
    langs.map(function(){
        var ch =$(this);
        if(ch.prop('checked')){
            ch.prop('checked',false);
        }
        else{
            ch.prop('checked',true);
        }
        if(selectAll.prop('checked')){
            selectAll.prop('checked',false);
        }
        else{
            selectAll.prop('checked',true);
        }
    });
});